package com.dianxin.smartpark.web.visitor;

import java.io.IOException;
import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ZipUtil;
import com.chinatelecom.response.common.CommonResponseBody;
import com.dianxin.smartpark.dao.qo.visitor.SmartParkVisitorQO;
import com.dianxin.smartpark.service.visitor.SmartParkVisitorService;
import com.dianxin.smartpark.service.vo.common.DevicePullDataVo;
import com.dianxin.smartpark.service.vo.visitor.SmartParkVisitorQrVO;
import com.dianxin.smartpark.service.vo.visitor.SmartParkVisitorStaticVO;
import com.dianxin.smartpark.service.vo.visitor.SmartParkVisitorVO;
import com.dianxin.sso.client.annotation.RecordLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 访客管理
 * 
 * @author chenjiasong
 * @date 2021-07-28
 */
@RestController
@RequestMapping("/smartpark/visitor")
public class SmartParkVisitorController
{
    @Resource
    private SmartParkVisitorService smartParkVisitorService;

    /**
     * 查询访客管理列表
     */
    @PostMapping("/list")
    @SaCheckPermission(value = "/smartpark/visitor/list")
    public CommonResponseBody<List<SmartParkVisitorVO>>  list(@RequestBody SmartParkVisitorQO qo)
    {
        return smartParkVisitorService.selectSmartParkVisitorList(qo);
    }

    /**
     * 查询访客统计
     */
    @PostMapping("/static")
    @SaCheckPermission(value = "/smartpark/visitor/static")
    public CommonResponseBody<SmartParkVisitorStaticVO> visitorStatic(@RequestBody SmartParkVisitorQO qo)
    {
        return smartParkVisitorService.selectVisitorStatic(qo);
    }

    /**

     * 获取访客管理详细信息
     */
    @GetMapping(value = "/getInfo")
    @SaCheckPermission(value = "/smartpark/visitor/getInfo")
    public CommonResponseBody<SmartParkVisitorVO> getInfo(SmartParkVisitorQO qo)
    {
        return smartParkVisitorService.selectSmartParkVisitor(qo);
    }

    /**
     * 新增访客管理
     */
    @PostMapping("/add")
    @SaCheckPermission(value = "/smartpark/visitor/add")
    @RecordLog(name = "新增访客")
    public  CommonResponseBody<String> add(@RequestBody SmartParkVisitorVO vo) throws Exception {
        return smartParkVisitorService.insertSmartParkVisitor(vo);
    }

    /**
     * 修改访客管理
     */
    @PutMapping("/edit")
    @SaCheckPermission(value = "/smartpark/visitor/edit")
    @RecordLog(name = "修改访客")
    public  CommonResponseBody<Boolean> edit(@RequestBody SmartParkVisitorVO vo)
    {
        return smartParkVisitorService.updateSmartParkVisitor(vo);
    }

    /**
     * 删除访客管理
     */
	@DeleteMapping("/remove")
    @SaCheckPermission(value = "/smartpark/visitor/remove")
    @RecordLog(name = "删除访客")
    public  CommonResponseBody<Boolean> remove(@RequestBody SmartParkVisitorVO vo)
    {
        return smartParkVisitorService.deleteSmartParkVisitor(vo);
    }


    /**
     * 获取访客二维码链接
     */
    @GetMapping(value = "/qrcode/visitor")
    public CommonResponseBody<SmartParkVisitorVO> getQrCodeByVisitor(SmartParkVisitorQO qo)
    {
        return smartParkVisitorService.getQrCodeByVisitor(qo);
    }

    /**
     * 验证开门接口
     */
    @PostMapping("/qrcode/verify")
    public CommonResponseBody<SmartParkVisitorQrVO> verify(@RequestBody DevicePullDataVo vo) throws Exception {
        return smartParkVisitorService.qrCodeVerify(vo);
    }


}
